#ifndef ANIMATEFRAMEPANEL_H
#define ANIMATEFRAMEPANEL_H

#include <QWidget>
#include <QVector>
#include <QMouseEvent>
class AnimationFramePanel : public QWidget
{
	Q_OBJECT

public:
	AnimationFramePanel();
	AnimationFramePanel(QWidget *parent);
	~AnimationFramePanel();
	void paintEvent(QPaintEvent * event) override;
	void mousePressEvent(QMouseEvent * event) override;
	void mouseReleaseEvent(QMouseEvent * event) override;
	void mouseMoveEvent(QMouseEvent * event) override;
	virtual void onCurrentFrameChange();
	virtual void onStartFrameChange();
	virtual void onEndFrameChange();
	void pushLayer();
	void delLayer(int layer);
	void resizePanel();
	int layerCount();
private:
	enum class TOUCH_STATE{
		INVALID = -1,
		ON_FRAME,
		ON_FRAME_START,
		ON_FRAME_END,
	};
	int xToFrame(int x);
	int yToLayer(int y);
	const static int edgeSize = 20;
	const static int space_height = 5;
	const static int frame_flag_space = 10;
	const static int layer_block_height = 15;
	void drawAix();
	int _frame_count;
	int _current_frame;
	QVector<QPair<int,int>> _frame_start_ends;
	TOUCH_STATE _touchState;
	int _touchedLayer;
};

#endif // ANIMATEFRAMEPANEL_H
